package models

import (
	"database/sql"
	"time"
)

// AccountBalance 钱包表
// 钱包表

// AccountBalance 钱包表

type AccountBalance struct {
	Id              int64   `gorm:"column:id;               type:int(11);primary_key"                   json:"id"`
	UserId          int64   `gorm:"column:user_id;          type:bigint(20)         comment:用户ID"      json:"user_id"`
	WithDrawable    float64 `gorm:"column:with_drawable;    type:int(11);default:0; comment:可提现"      json:"with_drawable"`
	PendingTransfer float64 `gorm:"column:pending_transfer; type:int(11);default:0; comment:待转入"      json:"pending_transfer"`
	Frozen          float64 `gorm:"column:frozen;           type:int(11);default:0; comment:已冻结金额"   json:"frozen"`
	GiftCard        int     `gorm:"column:gift_card;        type:int(11);default:0; comment:礼品卡"      json:"gift_card"`
}

func (m *AccountBalance) TableName() string {
	return "account_balance"
}

// GiftCard 礼品卡表
type GiftCard struct {
	Id     int   `gorm:"column:id;type:int(11);primary_key"                         json:"id"`
	CardId int   `gorm:"column:card_id;type:int(11);primary_key"                   json:"card_id"`
	Amount int   `gorm:"column:amount;       type:int(11);    comment:礼品卡金额" json:"amount"`
	UserId int64 `gorm:"column:user_id;          type:bigint(20)         comment:用户ID"      json:"user_id"`
}

func (g *GiftCard) TableName() string {
	return "gift_cards"
}

// AlipayInfo 支付宝信息表
type AlipayInfo struct {
	Id            int    `gorm:"column:id;type:int(11);primary_key"                         json:"id"`
	UserId        int64  `gorm:"column:user_id;type:bigint(20)         comment:用户id"       json:"user_id"`
	UserName      string `gorm:"column:user_name;type:varchar(20);     comment:用户真实姓名"  json:"user_name"`
	AlipayAccount string `gorm:"column:alipay_account;type:varchar(20);comment:支付宝账号;"   json:"alipay_account"`
}

func (m *AlipayInfo) TableName() string {
	return "alipay_info"
}

// MoneyFlow 用户个人信息流水表
type MoneyFlow struct {
	ID          int64     `gorm:"primaryKey;column:id" json:"id"`
	FromUserID  int64     `gorm:"column:from_user_id" json:"from_user_id"`
	ToUserID    int64     `gorm:"column:to_user_id" json:"to_user_id"`
	Amount      float64   `gorm:"column:amount" json:"amount"`
	ArrivalTime time.Time `gorm:"column:arrival_time" json:"arrival_time"`
	Status      string    `gorm:"column:status" json:"status"`
	TaskID      int64     `gorm:"column:task_id" json:"task_id"`
}

func (m *MoneyFlow) TableName() string {
	return "money_flow"
}

// Recharge  充值订单表
type Recharge struct {
	Id           int64        `gorm:"column:id;type:bigint(20);primary_key        comment:订单id "                     json:"id" `
	UserId       int64        `gorm:"column:user_id;			type:bigint(20);	comment:用户ID"       json:"user_id" `
	Amount       float64      `gorm:"column:amount;			type:int(11);		comment:充值金额"          json:"amount" `
	RechargeTime sql.NullTime `gorm:"column:recharge_time;		type:timestamp;		comment:充值时间"      json:"recharge_time" `
	GetTime      sql.NullTime `gorm:"column:get_time;			type:timestamp;		comment:到账时间"      json:"get_time" `
	Status       string       `gorm:"column:status;	type:varchar(100) ;	comment:支付状态"                  json:"status" `
}

func (m *Recharge) TableName() string {
	return "recharge"
}

// Tasks 任务表
type Tasks struct {
	Id                    int64     `gorm:"column:id;				type:int(20);primary_key"                   json:"id,string"`
	PublisherId           int64     `gorm:"column:publisher_id;		type:bigint(20);	comment:发布人ID"         json:"publisher_id,string"`
	TaskName              string    `gorm:"column:task_name;			type:varchar(30);	comment:任务名称;"        json:"task_name"`
	PaymentFee            float64   `gorm:"column:payment_fee;				comment:支付费用;"        json:"payment_fee"`
	TaskContent           string    `gorm:"column:task_content;		type:varchar(300);	comment:任务内容;"        json:"task_content"`
	TaskType              string    `gorm:"column:task_type;			type:varchar(20);	comment:任务类型;"        json:"task_type"`
	TaskStatus            string    `gorm:"column:task_status;		type:varchar(20);	comment:任务状态0发布，1已接收，2已完成，3下架;"        json:"task_status"`
	PublishTime           string    `gorm:"column:publish_time;		type:varchar(100);		comment:发布时间"         json:"publish_time"`
	ReceiverId            int64     `gorm:"column:receiver_id;		type:bigint(20);	comment:接单人id"         json:"receiver_id,string"`
	ReceiverTime          string    `gorm:"column:receiver_time;		type:varchar(100);		comment:接单时间"         json:"receiver_time"`
	CompletionImage       string    `gorm:"column:completion_image;   type:varchar(20);   comment:任务完成图片"      json:"completion_image"`
	EndTime               time.Time `gorm:"column:end_time;			type:varchar(100);		comment:任务结束时间"      json:"end_time"`
	SystemConfirmTime     string    `gorm:"column:system_confirm_time;type:varchar(100);	comment:系统确认时间"      json:"system_confirm_time"`
	IsAfterSale           int       `gorm:"column:is_after_sale;		type:tinyint(1);	comment:是否售后"         json:"is_after_sale"`
	Notification          string    `gorm:"column:notification;		type:varchar(200);	comment:任务通知"         json:"notification"`
	OnlineTime            string    `gorm:"column:online_time;		type:varchar(100);		comment:任务上线时间"      json:"online_time"`
	CompletionTimeMinutes int       `gorm:"column:completion_time_minutes;type:int(11);	comment:任务多少分钟内完成" json:"completion_time_minutes"`
	//ReviewTime            int     `gorm:"column:review_time		;type:int(11);		comment:发布者审核任务时间" json:"review_time"`
	UpdateTime string `gorm:"column:update_time;		type:varchar(100);		comment:任务更新时间"      json:"update_time"`
}

func (m *Tasks) TableName() string {
	return "tasks"
}

// Users 用户个人信息表
type Users struct {
	Uid             int64  `gorm:"column:uid;				type:bigint(20);primary_key"                  json:"uid,string"`
	Nickname        string `gorm:"column:nickname;		type:varchar(30);     comment:昵称"            json:"nickname"`
	Password        string `gorm:"column:password;		type:varchar(300);	  comment:密码"            json:"password"`
	Gender          string `gorm:"column:gender;			type:varchar(5);      comment:性别"             json:"gender"`
	Phone           string `gorm:"column:phone;			type:varchar(15);     comment:手机号;"          json:"phone"`
	Email           string `gorm:"column:email;			type:varchar(16);     comment:邮箱"            json:"email"`
	Avatar          string `gorm:"column:avatar;			type:varchar(20);     comment:头像"            json:"avatar"`
	Campus          string `gorm:"column:campus;		 	type:varchar(10);     comment:校区"            json:"campus"`
	Bio             string `gorm:"column:bio;             type:varchar(300);    comment:个人简介"         json:"bio"`
	AccountStatus   string `gorm:"column:account_status;  type:varchar(20);     comment:账号状态"         json:"account_status"`
	AdminPermission string `gorm:"column:admin_permission;type:varchar(10);	  comment:管理权限"         json:"admin_permission"`
	RegisterTime    string `gorm:"column:register_time;   type:varchar(100);       comment:注册时间"         json:"register_time"`
	LoginTime       string `gorm:"column:login_time;DEFAULT:NULL;     type:varchar(100);       comment:最后一次登录时间"  json:"login_time"`
	UpdateTime      string `gorm:"column:update_time;     type:varchar(100);       comment:更新时间"         json:"update_time"`
	Token           string `gorm:"-"`
	FirstLogin      string `gorm:"-"`
}

func (m *Users) TableName() string {
	return "users"
}

// WorkOrders 工单表
type WorkOrders struct {
	Id              int    `gorm:"column:id;      			type:int(11);  primary_key"         json:"id"`
	TaskId          int    `gorm:"column:task_id; 			type:int(11)        comment:任务id"  json:"task_id"`
	Title           string `gorm:"column:title;   			type:varchar(100)   comment:标题"    json:"title"`
	Status          string `gorm:"column:status;  			type:varchar(20)    comment:状态:0进行中,1将金额还给发起者，2将金额发给接收者;"    json:"status"`
	Description     string `gorm:"column:description;			type:varchar(300)   comment:问题描述" json:"description"`
	AfterSaleAnswer string `gorm:"column:after_sale_answer;   type:varchar(300)   comment:售后解答" json:"after_sale_answer"`
	SubmitTime      string `gorm:"column:submit_time;			type:varchar(100);		comment:提交时间" json:"submit_time"`
	CompletionTime  string `gorm:"column:completion_time;		type:varchar(100);		comment:完成时间" json:"completion_time"`
	UpdateTime      string `gorm:"column:update_time;			type:varchar(100);		comment:更新时间" json:"update_time"`
}

func (m *WorkOrders) TableName() string {
	return "workorders"
}
